// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ViewDefinition.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.Robotics.Visualization
{
    using System;
    using System.Runtime.Serialization;
    using Microsoft.Robotics.Runtime;

    /// <summary>
    /// Provides the information needed to instantiate a visualization control (view). This information is read from the manifest.
    /// </summary>
    [DataContract(Name = "View")]
    public class ViewDefinition
    {
        /// <summary>
        /// The full type name of the visualization class.
        /// </summary>
        [DataMember(Name = "Type")]
        private string typeName = null;

        /// <summary>
        /// The name to use for the visualization tab.
        /// </summary>
        [DataMember(Name = "Name")]
        private string name = null;

        /// <summary>
        /// The name of the model agent to hook to.
        /// </summary>
        [DataMember(Name = "ModelAgent")]
        private string modelAgentName = null;

        /// <summary>
        /// The name of the model agent to hook to.
        /// </summary>
        [DataMember(Name = "IsStatusBarControl")]
        private bool isStatusBarControl;

        /// <summary>
        /// Initializes a new instance of the ViewDefinition class.
        /// </summary>
        /// <param name="name">The name to use for the visualization tab.</param>
        /// <param name="typeName">The full type name of the visualization class.</param>
        /// <param name="modelAgentName">The name of the model agent to hook to.</param>
        /// <param name="isStatusBarControl">Indicates whether the view is part of the status bar or the tab view</param>
        public ViewDefinition(string name, string typeName, string modelAgentName, bool isStatusBarControl = false)
        {
            this.name = name;
            this.typeName = typeName;
            this.modelAgentName = modelAgentName;
            this.isStatusBarControl = isStatusBarControl;
        }

        /// <summary>
        /// Initializes a new instance of the ViewDefinition class.
        /// </summary>
        /// <param name="name">The name to use for the visualization tab.</param>
        /// <param name="viewType">The type of the visualization class.</param>
        /// <param name="modelAgent">The model agent to hook to.</param>
        /// <param name="isStatusBarControl">Indicates whether the view is part of the status bar or the tab view</param>
        public ViewDefinition(string name, Type viewType, IAgent modelAgent, bool isStatusBarControl = false)
        {
            this.name = name;
            this.typeName = viewType.AssemblyQualifiedName;
            this.modelAgentName = modelAgent.Name;
            this.isStatusBarControl = isStatusBarControl;
        }

        /// <summary>
        /// Gets the full type name of the visualization class.
        /// </summary>
        public string TypeName
        {
            get
            {
                return this.typeName;
            }
        }

        /// <summary>
        /// Gets the name to use for the visualization tab.
        /// </summary>
        public string Name
        {
            get
            {
                return this.name;
            }
        }

        /// <summary>
        /// Gets the name of the model agent to hook to.
        /// </summary>
        public string ModelAgentName
        {
            get
            {
                return this.modelAgentName;
            }
        }

        /// <summary>
        /// Gets a value indicating whether the control is a status bar control (true) or a regular tab view (false)
        /// </summary>
        public bool IsStatusBarControl
        {
            get
            {
                return this.isStatusBarControl;
            }
        }
    }
}
